import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Mock using ESM

You can use your favorite **Mock** framework or tool and **Poku** together 🐷➕

> By not locking you into a specific set of plugins or mocking/spying tools, **Poku** promotes an open ecosystem where developers are free to integrate the tools that best suit their needs.

For this example, let's use the [**quibble**](https://github.com/testdouble/quibble), then testing its results with **Poku**:

<Tabs>
  <TabItem default value='./test/withdraw.test.js'>
  
    ```js
    import { assert } from 'poku';
    import quibble from 'quibble';

    await quibble.esm('../lib/funds.js', {
      // Original: 100
      getFunds: () => 200,
    });

    const { withdraw } = await import('../lib/withdraw.test.js');

    assert.strictEqual(withdraw(200), true, 'Mocking my funds to 200');

    assert.strictEqual(withdraw(300), false, "I can't get more than I have");

    await quibble.reset();
    ```

  </TabItem>
  <TabItem  value='./lib/funds.js'>

    ```js
    export const getFunds = () => 100;
    ```

  </TabItem>
  <TabItem  value='./lib/withdraw.js'>

    ```js
    import { getFunds } from './funds.js';

    export const withdraw = (value) => {
      const wallet = getFunds();

      return value <= wallet;
    };
    ```

  </TabItem>
</Tabs>

Then:

```bash
npx poku
```
